package com.koron.system.agent.business.controller;

import com.koron.bean.base.Response;
import com.koron.system.agent.business.bean.dto.AgentUserDto;
import com.koron.system.agent.business.bean.vo.AgentInfo;
import com.koron.system.agent.business.bean.vo.AgentVo;
import com.koron.system.agent.business.service.AgentService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;

/**
 * @ClassName AgentController
 * @description
 * @Author zhouj
 * @Date 2021/11/23 19:00
 */
@Api(tags = "代理")
@RestController
@RequestMapping("/agent/")
public class AgentController {

    @Autowired
    AgentService agentService;

    @ApiOperation(value = "授权")
    @PostMapping("authorize")
    public Response authorize(@RequestBody AgentUserDto agentUserDto) {
        return Response.ok(agentService.authorize(agentUserDto));
    }

    @ApiOperation(value = "取消授权")
    @PutMapping("cancel")
    public Response cancel(String leader, String agent) {
        return Response.ok(agentService.cancel(leader, agent));
    }

    @ApiOperation(value = "查询我的委托人列表")
    @GetMapping("queryAgentList")
    public Response<List<AgentVo>> queryAgentList(String leader) {
        return Response.ok(agentService.queryAgentList(leader));
    }

    @ApiOperation(value = "查询账号委托人信息(包含委托和被委托)有效期内")
    @GetMapping("queryAgentInfo")
    public Response<AgentInfo> queryAgentInfo(String leader) {
        return Response.ok(agentService.queryAgentInfo(leader));
    }

}
